<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
<h:head>

	<style type="text/css">
.ui-layout-north {
	z-index: 20 !important;
	overflow: visible;
}

.ui-layout-north .ui-layout-unit-content {
	overflow: visible;
}

.ui-widget {
	font-size: 9px !important;
}

.centro {
	top: 50%
}

.tabela {
	width: 800px;
}

.size {
	width: 800px;
	position: absolute;
	left: 17%;
	top: 10%;
}
</style>

	<script type="text/javascript">
		PrimeFaces.locales['pt'] = {
			closeText : 'Fechar',
			prevText : 'Anterior',
			nextText : 'Próximo',
			currentText : 'Começo',
			monthNames : [ 'Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio',
					'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro',
					'Novembro', 'Dezembro' ],
			monthNamesShort : [ 'Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun',
					'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez' ],
			dayNames : [ 'Domingo', 'Segunda', 'Terça', 'Quarta', 'Quinta',
					'Sexta', 'Sábado' ],
			dayNamesShort : [ 'Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb' ],
			dayNamesMin : [ 'D', 'S', 'T', 'Q', 'Q', 'S', 'S' ],
			weekHeader : 'Semana',
			firstDay : 0,
			isRTL : false,
			showMonthAfterYear : false,
			yearSuffix : '',
			timeOnlyTitle : 'Só Horas',
			timeText : 'Tempo',
			hourText : 'Hora',
			minuteText : 'Minuto',
			secondText : 'Segundo',
			ampm : false,
			month : 'Mês',
			week : 'Semana',
			day : 'Dia',
			allDayText : 'Todo o Dia'
		};
	</script>

	<title>Cadastro de Evento</title>
</h:head>

<h:body>

	<ui:decorate template="/templateBase.xhtml">
		<ui:define name="center">
			<p:growl id="growl" life="3000" />
			<h:form id="formCadEvento" acceptcharset="ISO-8859-1" lang="pt">
				<br />
				<br />
				<br />
				<p:panel styleClass="size" header="Cadastro de Evento"
					footer="Integração - Portal de Serviços e Comunicação">
					<p:tabView>
						<p:tab title="Principal">
							<br />
							<h:panelGrid>

								<h:outputText value="ID:" />
								<h:panelGrid columns="3">
									<p:inputText size="6" readonly="true"
										value="#{eventoBacking.evSalvar.id}" />
									<p:commandButton icon="ui-icon-search"
										oncomplete="dlgPesquisa.show()"
										update=":formPesquisa:tblPesquisa" />
								</h:panelGrid>

								<h:outputText value="Tipo de Evento:" />
								<p:selectOneMenu
									value="#{eventoBacking.codTipoEventoSelecionado}">
									<f:selectItem itemLabel="Selecione" itemDisabled="true" />
									<f:selectItems value="#{eventoBacking.listaTipoEvento}"
										var="tp" itemLabel="#{tp.descricao}" itemValue="#{tp.id}" />
								</p:selectOneMenu>

								<h:outputText value="Nome do Evento:" />
								<p:inputText size="80" required="true"
									requiredMessage="Informe o nome do evento!"
									value="#{eventoBacking.evSalvar.nomeEvento}" />


								<h:outputText value="C.H (horas):" />
								<p:inputText size="10" required="true"
									requiredMessage="Informe a carga horária do evento!"
									value="#{eventoBacking.evSalvar.cargaHoraria}" />

								<h:panelGrid columns="2">

									<h:panelGrid>

										<h:outputText value="Curso:" />
										<p:selectOneMenu value="#{eventoBacking.codCursoSelecionado}"
											required="true" requiredMessage="Informe o curso!">
											<f:selectItem itemLabel="Selecione" itemDisabled="true" />
											<f:selectItems value="#{eventoBacking.listaCursos}" var="c"
												itemLabel="#{c.nome}" itemValue="#{c.id}" />
										</p:selectOneMenu>

									</h:panelGrid>

									<h:panelGrid>

										<h:outputText value="Local:" />
										<p:selectOneMenu value="#{eventoBacking.codLocalSelecionado}"
											required="true" requiredMessage="Informe o local do evento!">
											<f:selectItem itemLabel="Selecione" itemDisabled="true" />
											<f:selectItems value="#{eventoBacking.listaLocal}" var="l"
												itemLabel="#{l.descricao}" itemValue="#{l.id}" />
										</p:selectOneMenu>

									</h:panelGrid>

								</h:panelGrid>


								<h:panelGrid columns="3">
									<h:panelGrid>
										<h:outputText value="Data Inicio:" />
										<p:calendar value="#{eventoBacking.evSalvar.dataInicial}"
											required="true" locale="pt"
											requiredMessage="Informe a data inicial do evento!" />
									</h:panelGrid>

									<h:panelGrid>
										<h:outputText value="a" />
									</h:panelGrid>

									<h:panelGrid>
										<h:outputText value="Data Final:" />
										<p:calendar value="#{eventoBacking.evSalvar.dataFinal}"
											required="true" locale="pt"
											requiredMessage="Informe a data final do evento!" />
									</h:panelGrid>
								</h:panelGrid>
							</h:panelGrid>
							<br />
							<p:separator />
							<br />
							<div align="center">
								<h:panelGrid columns="2">
									<p:commandButton value="Salvar" icon="ui-icon-check"
										actionListener="#{eventoBacking.salvarEvento}" ajax="false"
										update=":formPesquisa:tblPesquisa" />
									<p:commandButton value="Limpar" icon="ui-icon-cancel" />
								</h:panelGrid>
							</div>
							<br />
						</p:tab>


						<p:tab title="Programação">
							<br />
							<div align="right">
								<p:commandButton icon="ui-icon-plus" value="Adicionar"
									onclick="dlgConteudo.show()" />
							</div>
							<br />

							<p:dataTable
								emptyMessage="Nenhum conteúdo cadastrado para o evento!"
								value="#{eventoBacking.listaConteudo}" var="c" paginator="true"
								rows="10">

								<p:column headerText="Data">
									<div align="center">
										<h:outputText value="#{c.data}">
											<f:convertDateTime pattern="dd/MM/yyyy" />
										</h:outputText>
									</div>
								</p:column>
								<p:column headerText="Início">
									<div align="center">
										<h:outputText value="#{c.horaInicial}" />
									</div>
								</p:column>

								<p:column headerText="Fim">
									<div align="center">
										<h:outputText value="#{c.horaFinal}" />

									</div>
								</p:column>

								<p:column headerText="Contéudo">
									<h:outputText value="#{c.conteudo}" />
								</p:column>

								<p:column headerText="Excluir">
									<div align="center">

										<p:commandButton oncomplete="dlgConfirmacaoConteudo.show()"
											actionListener="#{eventoBacking.selecionaConteudoEvento(c)}"
											icon="ui-icon-cancel" />

									</div>
								</p:column>

							</p:dataTable>
						</p:tab>

						<p:tab title="Assinaturas">
							<br />
							<div align="right">
								<p:commandButton icon="ui-icon-plus" value="Adicionar"
									onclick="dlgAssinatura.show()" />
							</div>
							<br />
							<p:dataTable value="#{eventoBacking.listaAssinaturaEvento}"
								var="ae"
								emptyMessage="Nenhuma assinatura cadastrada para o evento!">

								<p:column headerText="Nome">
									<h:outputText value="#{ae.assinatura.nome}" />
								</p:column>

								<p:column headerText="Assina como:">
									<h:outputText value="#{ae.descricao}" />
								</p:column>

								<p:column headerText="Excluir">
									<div align="center">
										<p:commandButton oncomplete="dlgConfirmacaoAssinatura.show()"
											icon="ui-icon-cancel"
											actionListener="#{eventoBacking.selecionaAssinaturaEvento(ae)}" />
									</div>
								</p:column>

							</p:dataTable>
						</p:tab>

						<p:tab title="Certificado">
							<br />
							<h2>ATENÇÃO</h2>
							<h3>Ao inserir a imagem deve ser considerados os seguintes
								parametros:</h3>
							<h3>- Dimensões: (2300 X 1630)</h3>
							<h3>- O texto do certificado é na cor preta, portanto,
								coloque um fundo de modo que tenha sintonia com o texto.</h3>
							<p:fileUpload fileUploadListener="#{eventoBacking.enviarImagem}"
								label="Selecionar" invalidFileMessage="Formato inválido"
								showButtons="false" update=":formCadEvento" process="@all"
								allowTypes="/(\.|\/)(jpe?g|png|gif)$/" />
							<br />
							<br />
							<div align="center">
								<ui:repeat value="#{eventoBacking.imagem}" var="image">
									<p:graphicImage value="/images/fundoCertificado/#{image}"
										width="500" height="300" />
								</ui:repeat>
							</div>
						</p:tab>

					</p:tabView>
				</p:panel>
			</h:form>

			<p:dialog header="Pesquisa Eventos" widgetVar="dlgPesquisa"
				showEffect="clip" hideEffect="clip" closable="true"
				footer="Integração - Portal de Serviços e Comunicação" width="600"
				height="300">
				<h:form id="formPesquisa" prependId="false"
					acceptcharset="ISO-8859-1" lang="pt">

					<p:dataTable value="#{eventoBacking.listaEventos}" var="e"
						id="tblPesquisa" rows="10">

						<p:column headerText="ID">
							<h:outputText value="#{e.id}" />
						</p:column>

						<p:column headerText="Nome do Evento">
							<h:outputText value="#{e.nomeEvento}" />
						</p:column>

						<p:column headerText="Curso">
							<h:outputText value="#{e.curso.nome}" />
						</p:column>

						<p:column headerText="Local">
							<h:outputText value="#{e.localEvento.descricao}" />
						</p:column>

						<p:column>
							<p:commandButton icon="ui-icon-check"
								actionListener="#{eventoBacking.selecionaEvento(e)}"
								oncomplete="dlgPesquisa.hide()" update=":formCadEvento" />
						</p:column>

					</p:dataTable>
				</h:form>
			</p:dialog>

			<p:dialog header="Cadastro de Assinatura" widgetVar="dlgAssinatura"
				showEffect="clip" hideEffect="clip" closable="true"
				footer="Integração - Portal de Serviços e Comunicação" width="400"
				height="150">
				<h:form id="formAssinatura" prependId="false"
					acceptcharset="ISO-8859-1" lang="pt">

					<h:panelGrid>

						<h:outputText value="Nome" />
						<h:panelGrid columns="2">
							<p:inputText size="50" value="#{eventoBacking.assinaSalvar.nome}"
								readonly="true" />
							<p:commandButton icon="ui-icon-search"
								oncomplete="dlgPesquisaAssinatura.show()"
								update=":formPesquisaAssinatura" />
						</h:panelGrid>
						<h:panelGrid>
							<h:outputText value="Assinar como:" />
							<p:inputText size="50"
								value="#{eventoBacking.assEventoSalvar.descricao}" />
						</h:panelGrid>
					</h:panelGrid>
					<br />
					<br />
					<div align="center">
						<h:panelGrid columns="2">
							<p:commandButton value="Salvar" icon="ui-icon-check" ajax="false"
								actionListener="#{eventoBacking.salvaAssinatura}"
								update=":formCadEvento" />
							<p:commandButton value="Cancelar" icon="ui-icon-cancel"
								oncomplete="dlgAssinatura.hide()" />
						</h:panelGrid>
					</div>

				</h:form>
			</p:dialog>

			<p:dialog header="Cadastro de Conteúdo" widgetVar="dlgConteudo"
				showEffect="clip" hideEffect="clip" closable="true"
				footer="Integração - Portal de Serviços e Comunicação" width="600"
				height="350">
				<h:form id="formConteudo" prependId="false"
					acceptcharset="ISO-8859-1" lang="pt">

					<h:panelGrid>
						<h:outputText value="Data" />
						<p:calendar locale="pt" value="#{eventoBacking.ceSalvar.data}" />
						<h:panelGrid columns="2">
							<h:panelGrid>
								<h:outputText value="Hora Inicial" />
								<p:inputMask mask="99:99" size="10"
									value="#{eventoBacking.horaInicial}" />
							</h:panelGrid>
							<h:panelGrid>
								<h:outputText value="Hora Final" />
								<p:inputMask mask="99:99" size="10"
									value="#{eventoBacking.horaFinal}" />
							</h:panelGrid>
						</h:panelGrid>
						<h:outputText value="Conteúdo" />
						<p:inputTextarea autoResize="true" rows="5" cols="100"
							value="#{eventoBacking.ceSalvar.conteudo}" />
						<h:outputText
							value="Ministrantes - (Ex: Msc. Renan Victor Lalier, Msc. Lucas Costa)" />
						<p:inputTextarea autoResize="true" rows="5" cols="100"
							value="#{eventoBacking.ceSalvar.ministrante}" />
					</h:panelGrid>
					<br />
					<p:separator />
					<br />
					<div align="center">
						<h:panelGrid columns="2">
							<p:commandButton value="Salvar" icon="ui-icon-check"
								actionListener="#{eventoBacking.salvaConteudoEvento}"
								ajax="false" />
							<p:commandButton value="Cancelar" icon="ui-icon-cancel"
								oncomplete="dlgConteudo.hide()" />
						</h:panelGrid>
					</div>

				</h:form>
			</p:dialog>

			<p:dialog header="Pesquisa Assinatura"
				widgetVar="dlgPesquisaAssinatura" showEffect="clip"
				hideEffect="clip" closable="true"
				footer="Integração - Portal de Serviços e Comunicação" width="450"
				height="250">
				<h:form id="formPesquisaAssinatura" prependId="false"
					acceptcharset="ISO-8859-1" lang="pt">

					<p:dataTable value="#{eventoBacking.listaAssinatura}" var="a"
						rows="10" paginator="true"
						emptyMessage="Nenhuma assinatura encontrada na base de dados!">

						<p:column headerText="Nome">
							<h:outputText value="#{a.nome}" />
						</p:column>

						<p:column>
							<div align="center">
								<p:commandButton icon="ui-icon-check"
									actionListener="#{eventoBacking.selecionaAssinatura(a)}"
									update=":formAssinatura"
									oncomplete="dlgPesquisaAssinatura.hide()" />
							</div>
						</p:column>

					</p:dataTable>
				</h:form>
			</p:dialog>

			<p:dialog width="250" height="100" header="Confirmação"
				showEffect="clip" hideEffect="clip"
				widgetVar="dlgConfirmacaoAssinatura" closable="true"
				footer="Integração - Portal de Serviços e Comunicação">
				<h:form>

					<br />
					<h:outputText value="Deseja realmente excluir esta informação?" />
					<br />
					<br />
					<br />
					<div align="center">
						<h:panelGrid columns="2">
							<p:commandButton value="Sim" update=":formCadEvento" ajax="false"
								actionListener="#{eventoBacking.deletaAssinaturaEvento}" />
							<p:commandButton value="Não"
								oncomplete="dlgConfirmacaoAssinatura.hide()" />
						</h:panelGrid>
					</div>
				</h:form>
			</p:dialog>

			<p:dialog width="250" height="100" header="Confirmação"
				showEffect="clip" hideEffect="clip"
				widgetVar="dlgConfirmacaoConteudo" closable="true"
				footer="Integração - Portal de Serviços e Comunicação">
				<h:form>

					<br />
					<h:outputText value="Deseja realmente excluir esta informação?" />
					<br />
					<br />
					<br />
					<div align="center">
						<h:panelGrid columns="2">
							<p:commandButton update=":formCadEvento" value="Sim"
								actionListener="#{eventoBacking.deletaConteudoEvento}"
								ajax="false" />
							<p:commandButton value="Não"
								oncomplete="dlgConfirmacaoConteudo.hide()" />
						</h:panelGrid>
					</div>
				</h:form>
			</p:dialog>


		</ui:define>
	</ui:decorate>
</h:body>
</html>